<template>
  <main class="main-container">
    <DeviceSearchBar></DeviceSearchBar>
    <div class="reader-container">
      <div>
        <el-text>设备逻辑名：</el-text>
        <el-select
          style="margin-top: 4px"
          placeholder="请选择设备逻辑名"
          v-model="deviceWriter.deviceName"
        >
          <el-option
            v-for="typeItem in deviceStore.deviceNames"
            :key="typeItem"
            :value="typeItem"
            :label="typeItem"
          ></el-option>
        </el-select>
      </div>
      <div style="margin-top: 10px">
        <el-text>数据类型：</el-text>
        <el-select
          style="margin-top: 4px"
          placeholder="请选择数据类型"
          v-model="deviceWriter.dataType"
        >
          <el-option
            v-for="typeItem in deviceStore.dataTypes"
            :key="typeItem"
            :value="typeItem"
            :label="typeItem"
          ></el-option>
        </el-select>
      </div>
      <div style="margin-top: 10px">
        <el-text>设备点位地址：</el-text>
        <el-input
          style="margin-top: 4px"
          v-model="deviceWriter.address"
          maxlength="15"
          placeholder="请输入设备点位地址"
          type="text"
        ></el-input>
      </div>

      <div style="margin-top: 10px">
        <el-text>写入的数据值：</el-text>
        <el-input
          style="margin-top: 4px"
          v-model="deviceWriter.writeValue"
          type="text"
        ></el-input>
        <el-button style="width: 100%; margin-top: 10px" type="primary">
          写入数据
        </el-button>
      </div>
    </div>
  </main>
</template>

<script setup lang="ts">
import DeviceSearchBar from "@/components/device/device-search-bar.vue";
import { useDeviceManagerStore } from "@/store/device/manager";
import { useDeviceWriterStore } from "@/store/device/writer";
import { ref } from "vue";

const deviceStore = useDeviceManagerStore();
const deviceWriter = useDeviceWriterStore();
</script>

<style scoped>
.main-container {
  height: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
}

.reader-container {
  height: 100%;
  padding: 20px 30px 20px;
  background-color: #fff;
  border: 1px solid #ddd;
  margin-top: 10px;
  border-radius: 5px;
}
</style>
